﻿using System;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Prism.Ioc;

namespace aichat
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow(IContainerProvider containerProvider)
        {
            try
            {
                InitializeComponent();
                var viewModel = containerProvider.Resolve<MainWindowViewModel>();
                if (viewModel != null)
                {
                    DataContext = viewModel;
                }
                else
                {
                    MessageBox.Show("无法解析MainWindowViewModel", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"MainWindow初始化失败: {ex.Message}\n\n异常类型: {ex.GetType().Name}\n\n堆栈跟踪:\n{ex.StackTrace}", 
                    "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
    }
}